package com.hengpeng.itfin.service.activity.impl;

import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.hengpeng.itfin.common.MessageUtil;
import com.hengpeng.itfin.service.activity.RewadMovieService;
import com.hengpeng.itfin.service.impl.BaseServiceImpl;
import com.hengpeng.itfinbase.constants.RespCodeConstants;
import com.hengpeng.itfinbase.en.ActivityStatus;
import com.hengpeng.itfinbase.message.ResponseMessage;
import com.hengpeng.itfinbase.message.activity.InvestSendMovieTicketRequest;
import com.hengpeng.itfinbase.persist.Activity;

@Transactional
@Service
@Lazy
public class RewadMovieServiceImpl extends BaseServiceImpl implements RewadMovieService {

    @Override
    public ResponseMessage investSendMovieTicket(InvestSendMovieTicketRequest request) {
        if (request.getUserId() == null || request.getActivityType() == null) {
            return MessageUtil.getErrorResponseMessage(ResponseMessage.class,
                    RespCodeConstants.CommonCode.DATA_NOT_VALIDATA, "参数错误");
        }
        logger.info("开始进入活动[transtype=" + request.getTransType() + "][activityType=" + request.getActivityType()
                + "]业务操作");
        Activity activity = daoFactory.getActivityDao().getActivityByType(request.getActivityType());
        if (activity.getStatus() != ActivityStatus.ACTIVE) {
            return MessageUtil.getErrorResponseMessage(ResponseMessage.class, RespCodeConstants.CommonCode.TRANS_FAIL,
                    "活动已暂停或还未开始");
        }
        /**
         * TODO 对接电影票接口
         */
        // Set<Reward> rewards = activity.getRewards();
        // RewardMovie rewardMovie = new RewardMovie();
        // rewardMovie.setActiveId(activeId);
        // rewardMovie.setCreateTime(createTime);
        // rewardMovie.setEndtime(endtime);
        // rewardMovie.setGettime(gettime);
        // rewardMovie.setRewardId(rewardId);
        // rewardMovie.setStatus(status);
        // rewardMovie.setTicketId(ticketId);
        // rewardMovie.setUpdateTime(updateTime);
        // rewardMovie.setUserId(userId);
        // rewardMovie.setUserName(userName);
        // daoFactory.getRewardMovieDao().save(rewardMovie);
        logger.info("活动[transtype=" + request.getTransType() + "]业务操作结束");
        return null;
    }
}
